package com.zengdw.storage.controller;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zengdw.storage.entity.StorageTbl;
import com.zengdw.storage.service.StorageTblService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zengdw
 * @createTime 2019/12/24 10:13
 */
@RestController
public class IndexController {
    @Resource
    private StorageTblService storageTblService;

    @PostMapping("/update")
    public void update(@RequestParam Integer id, @RequestParam Integer count){
        LambdaUpdateWrapper<StorageTbl> wrapper = Wrappers.<StorageTbl>lambdaUpdate().setSql("count = count - " + count).eq(StorageTbl::getId, id);
        storageTblService.update(wrapper);
    }
}
